package com.liangzong.betspider.executor;

import com.liangzong.betspider.enums.CommandEnum;
import com.liangzong.betspider.command.SyncTeamStateCMD;
import com.liangzong.betspider.service.TeamInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class SyncTeamStateExecutor implements Executor<SyncTeamStateCMD> {

    @Autowired
    TeamInfoService teamInfoService;

    @Override
    public boolean support(CommandEnum commandEnum) {
        return commandEnum == CommandEnum.OVERTIME;
    }

    @Override
    public void process(SyncTeamStateCMD command) {
        List<String> syncInfoList = command.getSyncInfoList();
        log.info(syncInfoList.toString());
        if(syncInfoList!=null && !syncInfoList.isEmpty()) {
            teamInfoService.updateStateByUrl(syncInfoList);
        }
    }
}
